<template>
    <div class="tab-control">
        <div v-for="(item ,index) in titles" :key="index" class="tab-control-item"
        @click="reindex(index)"
        :class="{activea: index === currentindex}"
        >
            <span>{{item}}</span>
        </div>
    </div>
</template>

<script>
    export default {
        name: 'TabControl',
        props: {
            titles: {
                type: Array,
                default(){
                    return []
                }
            }
        },
        data () {
            return {
                currentindex : 0
            }
        },
        methods: {
            reindex (index) {
                this.currentindex =  index
                console.log(this.currentindex);
                console.log(index); 
            }
        }
    }
</script>

<style>
    .tab-control {
        display: flex;
        text-align: center;
        font-size: 15px;
        background-color: #fff;
    }
    .tab-control-item{
        flex: 1;
        height: 40px;
        line-height: 40px;  
        /* background-color: pink;     */
    }
    .activea {
        color: #FA2800;

    }
    .activea span {
        padding: 3px;
        border-bottom: 2px solid #FA2800;
    }

</style>